import unittest
from ddt import ddt, data, unpack

test_list = [1, 5, 6, 9, 8, 2]


def liner_searching(list, size, target):
    for i in range(0, size):
        if (list[i] == target):
            return i
    return -1


@ddt
class AddTestCase(unittest.TestCase):

    def setUp(self):
        print("test method start ……>")

    @data([test_list, len(test_list), 1, 0], [test_list, len(test_list), 2, 5], [test_list, len(test_list), -1, -1])
    @unpack
    def test_abs(self, x, y, z, expect_value):
        result = liner_searching(x, y, z)
        self.assertEqual(result, expect_value, msg=result)

    # 代码清理
    def tearDown(self):
        print("test method end ……")


if __name__ == '__main__':
    unittest.main(verbosity=2)
